package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JsonUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class TravelCommend extends BaseDomain{
    public static final Integer TYPE_WEEK = 1;
    public static final Integer TYPE_MONTH = 2;
    public static final Integer TYPE_STRATEGY = 3;

    private Long travelId;

    private String title;

    private String subTitle;

    private String coverUrl;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule;

    private Integer type;

    public String getTypeName(){
        String typeName = "每周推荐";
        if (type == TYPE_MONTH){
            typeName = "每月推荐";
        }else if (type == TYPE_STRATEGY){
            typeName = "攻略推荐";
        }
        return typeName;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("travelId",travelId);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule",new SimpleDateFormat("yyyy-MM-dd").format(schedule));
        map.put("type",type);
        return JsonUtil.toJsonString(map);
    }
}